package com.piece.core.mongo.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import java.io.Serializable;
import java.util.Date;

/**
 * 网站访问限制名单 sys_stream_block
 */
@Data
@NoArgsConstructor
@Document(collection = "sys_stream_block")
@CompoundIndexes({
        @CompoundIndex(name = "index_sys_stream_block", def = "{'ip':1,'block_time':1}")
})
public class MongoStreamBlock implements Serializable {

    /**
     * 黑名单主键
     */
    @Id
    private String id;

    /**
     * 访问IP
     */
    @Field("ip")
    private String ip;

    /**
     * 登录城市
     */
    @Field("city")
    private String city;

    /**
     * 登录地点
     */
    @Field("area")
    private String area;

    /**
     * 禁用时间
     */
    @Field("block_time")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date blockTime;
}